<?php

namespace app\admin\validate;

use think\Validate;

class Admin extends Validate
{
    protected $rule = [
        'username' => 'require|length:5,20|alphaDash|unique:admin',
        'password' => 'require|length:6,12|alphaNum|confirm',
        'email' => 'require|email',
        'code' => 'require|captcha',
    ];
    protected $message = [
        'username.require' => '账号填写',
        'code.require' => '验证码必须填写',
        'code.captcha' => '验证码错误',
        'username.length' => '账号长度为5到20个字符',
        'username.alphaDash' => '账号只能由字母、数字和下划线组成',
        'username.unique' => '该账号已经存在',
        'password.require' => '密码必须填写',
        'password.length' => '密码长度为6到12个字符',
        'password.alphaNum' => '密码只能由字母和数字组成',
        'password.confirm' => '两次密码输入不一致',
        'email.require' => '邮箱必须填写',
        'email.email' => '邮箱格式不对',
    ];
    protected $scene = [
        'create' => ['username', 'password'],
        'update' => ['password' => 'length:6,12|alphaNum|confirm', 'username'],
        'login' => ['password' => 'length:6,12|alphaNum|require', 'username' => 'require|length:5,20|alphaDash', 'code'],
    ];
}